<template>
  <div class="dashboard-container">
    <div class="app-container">
      <el-card>
        <el-tabs>
          <!-- 放置页签 -->
          <el-tab-pane label="登录账户设置">
            <div class="form-container">
              <el-form label-width="80px">
                <el-form-item label="用户名">
                  <el-input v-model="userInfo.username" />
                </el-form-item>
                <el-form-item label="密码">
                  <el-input v-model="userInfo.password2" type="password" />
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" @click="saveUser">保存</el-button>
                </el-form-item>
              </el-form>
            </div>
          </el-tab-pane>
          <el-tab-pane label="个人详情">
            <user-info />
          </el-tab-pane>
          <el-tab-pane label="岗位信息">
            <job-info />
          </el-tab-pane>
        </el-tabs>
      </el-card>
    </div>
  </div>
</template>

<script>
import { getUserDetail } from '@/api/user'
import { saveUserDetailById } from '@/api/employees'
import UserInfo from './components/user-info.vue'
import jobInfo from './components/job-info.vue'
export default {
  name: '',
  components: { jobInfo, UserInfo },
  props: {
    id: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      userInfo: {
        //   专门存放基本信息
        username: '',
        password2: ''
      }
    }
  },
  created() {
    // console.log(this.$route.params.id)
    console.log(this.id)
    this.getUserDetail()
  },
  methods: {
    async getUserDetail() {
      this.userInfo = await getUserDetail(this.id)
    },
    async saveUser() {
      await saveUserDetailById(this.userInfo)
      this.$message.success('保存成功')
    }
  }
}
</script>

<style scoped lang="scss">
.form-container {
  width: 40%;
  margin: 0 auto;
}
</style>
